import axios from 'axios'

// 获取新歌API
const getNewSongAPI = (url: string) => {
    let ins = axios.create({
        baseURL:'http://localhost:3002/personalized',
        timeout:2000
    })

    return ins.get(url);
}

// 获取推荐歌单API
const getresourceAPI = (limit: string | number) => {
    return axios({
        baseURL:'http://localhost:3002/top/playlist/highquality?',
        timeout:2000,
        params:{
            limit:limit
        }
    })
    

}

// 获取热门明星API
const getStartAPI = (url: string) => {
    let ins = axios.create({
        baseURL:'http://localhost:3002/top',
        timeout:2000
    })

    return ins.get(url);
}
// 获取手机验证码API
const getCodeAPI = (phone:any) =>{
    // let ins = axios.create({
    //     baseURL:`/captcha/sent?phone=`,
    //     timeout:2000
    // })
    return axios({
        method:'get',
        baseURL:`http://localhost:3002/captcha/sent?`,
        params:{
            phone:phone
        }
    })
}
// 验证验证码
const captchaCodeAPI = (phone:any,code:any) => {
    return axios({
        method:'get',
        baseURL:`http://localhost:3002/login/cellphone?`,
        params:{
            phone:phone,
            captcha:code
        }
    })
}
// 获取发现页面歌单分类
const playlistClassilyAPI = (url:any)=>{
    let ins = axios.create({
        baseURL:'http://localhost:3002/playlist/',
        timeout:2000
    })
    return ins.get(url);
}
//获取相应分类中的歌单
const playlistAPI = (cat:any) =>{
    return axios({
        method:'get',
        baseURL:'http://localhost:3002/top/playlist?',
        params:{
            cat:cat
        }
    })
}
//获取最新MV
const newMvAPI = (limitValue:number) =>{
    return axios({
        method:'get',
        baseURL:'http://localhost:3002/mv/first?',
        params:{
            limit:limitValue
        }
    })
}
//获取网易出品MV
const WYMvAPI = (limitValue:number) =>{
    return axios({
        method:'get',
        baseURL:'http://localhost:3002/mv/exclusive/rcmd?',
        params:{
            limit:limitValue
        }
    })
}
//获取推荐MV
const personalizedMvAPI = (val:any) =>{
    return axios({
        method:'get',
        baseURL:'http://localhost:3002/personalized/mv',
    })
}
// 根据相应的id查询MV详情
const mvDetailsAPI = (id:number) =>{
    return axios({
        method:'get',
        baseURL:'http://localhost:3002/mv/detail?',
        timeout:2000,
        params:{
            mvid:id
        }
    })
}
// 根据相应ID查找MV地址
const VideoUrlAPI = (id:number) =>{
    return axios({
        method:'get',
        baseURL:'http://localhost:3002/mv/url?',
        timeout:2000,
        params:{
            id:id
        }

    })
}
//根据id获取相似的MV
const simiMvAPI = (id:number) =>{
    return axios({
        method:'get',
        baseURL:'http://localhost:3002/simi/mv?',
        timeout:2000,
        params:{mvid:id}
    })
}
// 传输对应的歌单id和登陆cookie状态拿歌单详情页
const songSheetAPI = (songSheeId:number,cookie:string | null) =>{
    return axios({
        method:'get',
        baseURL:'http://localhost:3002/playlist/detail?',
        params:{
            id:songSheeId,
            cookie:cookie
        },
        timeout:2000,
    })
}
// 获取歌单全部歌曲
const AllsongSheetAPI = (songSheeId:number,cookie:string | null) =>{
    return axios({
        method:'get',
        baseURL:'http://localhost:3002/playlist/track/all?',
        params:{
            id:songSheeId,
            cookie:cookie
        },
        timeout:2000,
    })
}

const API = {
    getNewSongAPI,getresourceAPI,getStartAPI,mvDetailsAPI,VideoUrlAPI,
    getCodeAPI,captchaCodeAPI,playlistAPI,playlistClassilyAPI,newMvAPI,
    WYMvAPI,personalizedMvAPI,simiMvAPI,songSheetAPI,AllsongSheetAPI
}

export default API